<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>地址管理</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
    <script type="text/javascript" src="../shop-style/js/jquery.js"></script>
    <script type="text/javascript" src="../shop-style/js/index.js"></script>
    <script src="../shop-style/script/global.js" type="text/javascript"></script>
    <script src="../shop-style/script/head.js" type="text/javascript"></script>
    <link rel="stylesheet" type="text/css" href="../shop-style/css/main.css"/>
    <link rel="stylesheet" type="text/css" href="../shop-style/css/basic.css">
    <link rel="stylesheet" type="text/css" href="../shop-style/css/style.css" />
    <link rel="stylesheet" href="../shop-style/style/base.css" />
    <link rel="stylesheet" href="../shop-style/style/head.css" />

    <link rel="stylesheet" type="text/css" href="../../h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="../../h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="../../lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="../../h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="../../h-ui.admin/css/style.css" />
</head>
<body>

<!-- 插入公共模板 _top -->
<div th:replace="../templates/user/common/_top :: common_top"></div>

<!-- 插入公共模板 _headNav -->
<div th:replace="../templates/user/common/_headNav :: common_headNav"></div>


<!--中部 start-->
<div class="con_ny">
    <div class="danye">
        <!-- 左侧导航 start -->
        <!-- 插入公共模板 _user_center_left -->
        <div th:replace="../templates/user/common/_user_center_left :: common_user_center_left"></div>
        <!-- 左侧导航 end -->

        <!--单页详情开始-->
        <div class="danye_right">
            <div class="danye_dqbt">
                <span class="jj_t"></span>
                <span class="dq_dy">您的当前位置：<a th:href="@{/goodsAction/goIndex}">首页</a> >> 用户中心 >> 地址管理</span>
            </div>
            <!--会员中心右侧开始-->
            <div class="hyzx_yc">
                <div class="cl pd-5 bg-1 bk-gray mt-20">
                    <span class="l">
                        <a href="javascript:;" onclick="receive_add('添加地址','goUserReceiveAdd','','510')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加地址</a>
                    </span>
                </div>
                <div class="mt-20">
                    <table class="table table-border table-bordered table-hover table-bg table-sort">
                        <thead>
                        <tr class="text-c">
                            <th width="60">收货人</th>
                            <th width="80">手机号码</th>
                            <th width="180">所在地区</th>
                            <th width="200">详细地址</th>
                            <th width="60">是否为默认地址</th>
                            <th width="80">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr class="text-c" th:each="userReceive : ${userReceiveList}">
                            <td th:text="${userReceive.contact}"></td>
                            <td th:text="${userReceive.tel}"></td>
                            <td th:text="|${userReceive.receiveProvince} - ${userReceive.receiveCity} - ${userReceive.receiveCounty}|"></td>
                            <td th:text="${userReceive.receiveAddress}"></td>
                            <td class="td-status">
                                <span class="label label-success radius" th:if="${userReceive.isdefault == 1}">默认地址</span>
                            </td>
                            <td class="td-manage">
                                <a style="text-decoration:none" th:onClick="|receive_isdefault(${userReceive.receiveId})|" href="javascript:;" title="设为默认地址"><i class="Hui-iconfont">&#xe6e1;</i></a>
                                <a style="text-decoration:none" class="ml-5" th:onclick="|receive_edit('编辑','goUserReceiveEdit',${userReceive.receiveId},'','510')|" title="编辑" href="javascript:;" ><i class="Hui-iconfont">&#xe6df;</i></a>
                                <a title="删除" href="javascript:;" th:onclick="|receive_del(this,${userReceive.receiveId})|" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <!--会员中心右侧结束-->
        </div>
        <!--单页详情结束-->
    </div>
</div>
<!--中部 end-->


<div class="none" style="height:20px;"></div>

<div th:replace="../templates/user/common/_footer :: common_footer"></div>

<script type="text/javascript" src="../../../lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="../../../lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="../../../h-ui/js/H-ui.js"></script>
<script type="text/javascript" src="../../../h-ui.admin/js/H-ui.admin.page.js"></script>

<script type="text/javascript">
    /*地址-添加*/
    function receive_add(title,url,w,h){
        layer_show(title,url,w,h);
    }

    /*地址-编辑*/
    function receive_edit(title,url,receiveId,w,h){
        url = url + "?receiveId=" + receiveId;
        layer_show(title,url,w,h);
    }

    /*地址-删除*/
    function receive_del(obj,receiveId){
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
                type: "GET",
                dateType: "json",
                url: "/userReceiveAction/doUserReceiveDelete",
                data:{receiveId:receiveId},
                success: function (result) {
                    if(result.flag = "true") {
                        $(obj).parents("tr").remove();
                        layer.msg('已删除!',{icon:1,time:1000});
                    } else {
                        layer.msg('删除失败!',{icon: 2,time:1000});
                    }
                },
                error: function (err) {
                    layer.msg('请求异常!',{icon: 2,time:1000})
                }
            });

        });
    }

    /*设为默认地址*/
    function receive_isdefault(receiveId) {
        $.ajax({
            url: "/userReceiveAction/doDefault",
            cache: false,
            type: "GET",
            dateType: "json",
            async: true,
            data:{receiveId:receiveId},
            success: function (result) {
                if(result.flag = "true") {
                    layer.msg('设置成功，请刷新!',{icon:1,time:1000});
                } else {
                    layer.msg('设置失败!',{icon: 2,time:1000});
                }
            },
            error: function (err) {
                layer.msg('请求异常!',{icon: 2,time:1000})
            }
        });
    }

</script>

</body>
</html>
